const app = getApp();
Page({
  data: {
    list:{
      price: 0
    },
    listData:{}
  },
  recharge:function(){
    wx.navigateTo({
      url: '../mineBalanceCash/mineBalanceCash?type=recharge'
    })
  },
  withdrawal:function(){
    wx.navigateTo({
      url: '../mineBalanceCash/mineBalanceCash?type=withdrawal'
    })
  },
  onLoad: function (options){
    wx.setNavigationBarTitle({
      title: '余额',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const that = this;
    app.util.request({
      url: 'Index/Index/getBalance',
      data: {
        openid: app.globalData.userInfo.openid
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        if (res.data === null || res.data.length == 0) {
          console.log('暂无数据');
        } else {
          that.setData({
            list: res.data
          })
        }
      }
    })
    app.util.request({
      url: 'Index/Index/getBalanceLog',
      data: {
        openid: app.globalData.userInfo.openid
      },
      header: {
        'content-type': 'application/json'
      },
      success(res) {
        if (res.data === undefined || res.data.length == 0) {
          console.log('暂无数据');
        } else {
          that.setData({
            listData: res.data
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})